using System.Configuration;

namespace Microsoft.ConnectionEngine.SampleDeploymentManager.Configuration
{
    internal class WizardPageConfigCollection : ConfigurationElementCollection
    {
        #region Public properties
        public override ConfigurationElementCollectionType CollectionType
        {
            get { return ConfigurationElementCollectionType.AddRemoveClearMap; }
        }

        public new string AddElementName
        {
            get { return base.AddElementName; }
            set { base.AddElementName = value; }
        }

        public new string ClearElementName
        {
            get { return base.ClearElementName; }
            set { base.AddElementName = value; }
        }

        public new string RemoveElementName
        {
            get { return base.RemoveElementName; }
        }

        public new int Count
        {
            get { return base.Count; }
        }

        public WizardPageConfig this[int index]
        {
            get { return ((WizardPageConfig)(BaseGet(index))); }
            set
            {
                if (!((BaseGet(index) == null)))
                {
                    BaseRemoveAt(index);
                }
                BaseAdd(index, value);
            }
        }

        public new WizardPageConfig this[string name]
        {
            get { return ((WizardPageConfig)(BaseGet(name))); }
        }
        #endregion

        #region Public methods
        public int IndexOf(WizardPageConfig url)
        {
            return BaseIndexOf(url);
        }

        public void Add(WizardPageConfig url)
        {
            BaseAdd(url);
        }

        public void Remove(WizardPageConfig url)
        {
            if (BaseIndexOf(url) >= 0)
            {
                BaseRemove(url.Name);
            }
        }

        public void RemoveAt(int index)
        {
            BaseRemoveAt(index);
        }

        public void Remove(string name)
        {
            BaseRemove(name);
        }

        public void Clear()
        {
            BaseClear();
        }
        #endregion

        #region Protected methods
        protected override ConfigurationElement CreateNewElement()
        {
            return new WizardPageConfig();
        }

        protected override object GetElementKey(ConfigurationElement element)
        {
            return ((WizardPageConfig)(element)).Name;
        }

        protected override void BaseAdd(ConfigurationElement element)
        {
            BaseAdd(element, false);
        }
        #endregion
    }
}
